package com.cyh.ebpttoolswar.tools;

import com.cyh.ebpttoolswar.commmon.EntityGenerator;
import com.cyh.ebpttoolswar.entitys.Config;
import com.cyh.ebpttoolswar.entitys.SsmConfig;

import java.sql.SQLException;

public class generateMybatiseConfigBySelf {
  public static void main(String arg[]) throws SQLException, ClassNotFoundException {
    // 用户名
    String DBUSER = "ebptdb";
    // 密码
    String DBPASS = "ebptuser";
    // 输出目录
    String SRCPath = "ebptpub-jar/src/main/java/com/cyh/ebptpubjar";
    String TABLE_SCHEMA = "ebptbase";
    String DEFAULT_PACKAGE = "ebpttools-war";
    String DBURL =
        "jdbc:mysql://" + "127.0.0.1:3306" + "/" + TABLE_SCHEMA + "?characterEncoding=utf8";
    Config config = buildConfig(DEFAULT_PACKAGE, SRCPath, TABLE_SCHEMA,"ebpt_test_mysqlnomarlfield");
    // 设置作者
    config.setAuthor("cyh");
    EntityGenerator e = new EntityGenerator();
    e.generator(config, DBURL, DBUSER, DBPASS);
  }

  public static Config buildConfig(String DEFAULT_PACKAGE, String SRCPath, String TABLE_SCHEMA,String tableName) {
    SsmConfig ssmConfig = new SsmConfig();
    ssmConfig.setDefaultPackageName(DEFAULT_PACKAGE);
    ssmConfig.setDefault();
    ssmConfig.setSrcPath(SRCPath);
    ssmConfig.setTableSchema(TABLE_SCHEMA);
    ssmConfig.setTableName(tableName);
    return ssmConfig;
  }
}
